package com.sskj.level.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.rxbus2.RxBus;
import com.sskj.level.bean.TradeInfoBean;
import com.sskj.level.http.HttpConfig;
import com.sskj.level.ui.fragment.LevelFragment;
import com.sskj.lib.bean.CoinBean;
import com.sskj.lib.bean.UserData;
import com.sskj.lib.http.JsonCallBack;

import java.util.List;


public class LevelFragmentPresenter extends BasePresenter<LevelFragment> {


    public void getProduct(String code) {
        httpService.getPro(code)
                .execute(new JsonCallBack<HttpData<List<CoinBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<CoinBean>>> response) {
                        HttpData<List<CoinBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            RxBus.getDefault().post(httpData.getData().get(0));
//                            mView.updateUI(httpData.getData().get(0));
                        }
                    }
                });
    }



    /**
     * 首页行情列表
     *
     * @param code 标识符
     * @return
     */
    public void getPro(String code) {
        httpService.getPro(code).execute(new JsonCallBack<HttpData<List<CoinBean>>>() {
            @Override
            public void onSuccess(Response<HttpData<List<CoinBean>>> response) {
                HttpData<List<CoinBean>> httpData = response.body();
                if (httpData.getStatus() == HttpConfig.OK) {
                    mView.updateUI(httpData.getData().get(0));
                }
            }
        });
    }

}
